
# -*- coding: utf-8 -*-
import scrapy
from testScrapy.items import ImageItem


class PeopleResSpider(scrapy.Spider):
    name = "peopleRes"
    allowed_domains = ["699pic.com"]
    start_urls = ['http://699pic.com/people.html']
    download_delay = 2

    def parse(self, response):
        item = ImageItem()
        srcs = response.xpath('//div[@class="swipeboxEx"]/div[@class="list"]/a/img/@data-original').extract()
        item['image_urls'] = srcs
        yield item

        next_page = response.xpath('//*[@class="downPage"]/@href').extract_first()
        if next_page is not None:
            next_page = response.urljoin(next_page)
            yield scrapy.Request(url= next_page, callback= self.parse)

